<?php
//------
// Configuracio
//------

// crear una lnea per a cada usuari... $usuari["usuari"]="password";
$usuari["38704221"]="5klst";

// Mail de desti del formulari
$email_desti="info@editorialnadal.com";

// On redireccionar quan s'acaba la comanda
$redireccio="http://www.editorialnadal.com";

//------
//------ Fi confifuracio
//------
session_start();
$cap="";
$comanda="";
while (list($key, $value) = each ($HTTP_POST_VARS)) {
	if (($value !="")&&($key!="x")&&($key!="y")&&($key!="PHPSESSID")){
		if (($key == "nombre")||($key=="telefono")||($key=="mail")||($key=="accio")){
			if ($key!= "accio"){
				$cap.=ucfirst($key).": ".$value."\n";
			}
			${$key} = $value;
		} else {
			if (($key=="usuario")||($key=="password")){
				${$key}=$value;
			} else {
				$comanda.=$key.": ".$value." exemplars\n";
			}
		}
	}
}
if ($password == ""){ $password=$usuario[$usuario]."po";}
if (($usuari[$usuario] == $password) ||( $_SESSION['login'] == 'true' )){
	$_SESSION['login'] = 'true';
} else {
	$e="Usuario o contrasea errneos";
	$img="retroceder";
	$js=" OnClick=\"window.history.go(-1)\"";
	$hr="#";
	$plantilla="../error.html";
	$thefile = implode("", file($plantilla));
	$thefile = str_replace("'","fuenteovejunatodosauna",$thefile);
	$thefile = addslashes($thefile);
	$thefile = str_replace("fuenteovejunatodosauna","'",$thefile);
	$thefile = "\$r_file=\"".$thefile."\";";
	eval($thefile);
	print $r_file;
	exit;
} 
function valid_email($email) {
    if (ereg("^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])*$",$email)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
if ($accio=="enviar"){
	$tmp=str_replace(" ","",$nombre);
	$tmp2=str_replace(" ","",$telefono);
	$tmp3=str_replace(" ","",$mail);
	$e="";
	if (($tmp =="")||($tmp2=="")||($tmp3=="")){
		$e="Ha d'omplir el camp de nom, telfon i mail";
	} else {
		if (!valid_email($mail)){
			$e="L'adrea de mail no s correcte";
		} 
	}
	if ($e!= ""){
		$img="retroceder";
		$js=" OnClick=\"window.history.go(-1)\"";
		$hr="#";
		$plantilla="../error.html";
		$thefile = implode("", file($plantilla));
		$thefile = str_replace("'","fuenteovejunatodosauna",$thefile);
		$thefile = addslashes($thefile);
		$thefile = str_replace("fuenteovejunatodosauna","'",$thefile);
		$thefile = "\$r_file=\"".$thefile."\";";
		eval($thefile);
		print $r_file;
		exit;
	}
	$cabecera="From: $mail\n";
	$cabecera.="Reply-to: $mail";
	$texte_mail=$cap."-----------------------------------------------------------\n".$comanda;
	if (mail($email_desti,"Comanda desde la Web Editorial Nadal",$texte_mail,$cabecera)){
		$texte_mail="Este es su pedido\n-----------------------------------------------------------\n".$texte_mail." \n-----------------------------------------------------------\n\n";
		$texte_mail.="Grcies per confiar en nosaltres.\nEditorial Nadal\nhttp://www.editorialnadal.com\n";
		mail($mail,"Comanda Editorial Nadal",$texte_mail,$cabecera);
		$e="La seva comanda ha estat enviada correctament. Tamb li hem enviat una copia de la comanda a $mail.<br><br>Gracies per confiar amb Editorial Nadal";
		$img="aceptar";
		$js="";
		$hr=$redireccio;
		if ($_SESSION['login'] != 'true' ) {	
			$_SESSION['login'] = 'false';
		}
	} else {
		$e="No ha estat possible enviar una copia de la seva comanda. Si us plau, intenti-ho un altre cop.";
		$img="retroceder";
		$js=" OnClick=\"window.history.go(-1)\"";
		$hr="#";
	}
	$plantilla="../error.html";
	$thefile = implode("", file($plantilla));
	$thefile = str_replace("'","fuenteovejunatodosauna",$thefile);
	$thefile = addslashes($thefile);
	$thefile = str_replace("fuenteovejunatodosauna","'",$thefile);
	$thefile = "\$r_file=\"".$thefile."\";";
	eval($thefile);
	print $r_file;
	exit;
}
?>
<HTML>
<HEAD>
<title>EDITORIAL NADAL</title>
<STYLE TYPE="text/css"><!--
BODY {
scrollbar-face-color: #D4D1C4; 
scrollbar-shadow-color: #908E85; 
scrollbar-highlight-color: #ffffff; 
scrollbar-3dlight-color: #908E85; 
  scrollbar-darkshadow-color: #D4D1C4; 
  scrollbar-track-color: #D4D1C4; 
  scrollbar-arrow-color: #65645D;
}
TD  { font-size : 11px; 	font-family : Verdana;	color : #6A6A6A;}
A:link  { text-decoration : none; font-family : Verdana; color: #6A6A6A;}
A:visited  {  text-decoration : none; font-family : Verdana; color : #6A6A6A;}
//--></STYLE>
<script language="javascript" type="text/javascript">
function hideLayer(whichLayer) {
	eval(whichLayer+'.style.display="none"');
}
function showLayer(whichLayer) {
	eval(whichLayer+'.style.display="block"');
	boton.style.display='block';
}
function inicia(){
	oc2.style.display='none';
	oc1.style.display='block';
}
</script>

<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript" src="../js/swfs.js"></script>

</HEAD>
<body bgcolor="#B51A00"  leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0" OnLoad="inicia()">
<FORM ACTION="pedidos_infprimaria.php" METHOD="POST">
<CENTER>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 width="764">
	<tr><td><img src="../images/trans.gif" height="10"></td></tr>
	<TR ALIGN="CENTER" VALIGN="MIDDLE">
	<TD>
	<!-- <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="764" height="229" id="llibre" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="swfs/catala/llibre.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="swfs/catala/llibre.swf" quality="high" bgcolor="#ffffff" width="764" height="229" name="llibre" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>-->
<div id="flash_llibre_catala" align="center"><script type="text/javascript">swf_llibre_catala.write("flash_llibre_catala");</script></div>
</TD>	
	</TR>
	<TR ALIGN="CENTER" VALIGN="MIDDLE">
	<td>
	<!-- <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="764" height="37" id="menu" align="middle">
	<param name="allowScriptAccess" value="sameDomain" />
	<param name="movie" value="swfs/catala/m_pedidos.swf" />
	<param name="quality" value="high" />
	<param name="bgcolor" value="#ffffff" />
	<embed src="swfs/catala/m_pedidos.swf" quality="high" bgcolor="#ffffff" width="764" height="37" name="menu" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
	</object>-->
	<div id="flash_pedidos_catala" align="center"><script type="text/javascript">swf_pedidos_catala.write("flash_pedidos_catala");</script></div>
	</td>
	</tr>
	<TR ALIGN="CENTER">
	<TD><IMG SRC="../images/blanc.gif" width="764" height="10"></TD>
	</TR>
	<TR bgcolor="EDEEE8" width="764" VALIGN="TOP">
	<td width="764" height="115" background="../images/bkgris.gif">
	<CENTER>
	<TABLE width="700" BORDER=0 CELLPADDING=0 CELLSPACING=0>
		<TR HEIGHT="30">
		<TD></TD>
		</TR>
		<TR>
		<TD COLSPAN=6>
		Empleneu les segents dades de contacte. <font color="6198AB">Aquests camps sn obligatoris.</font>
		</TD>
		</TR>
		<TR HEIGHT="30"><TD COLSPAN=6></TD></TR>

		<TR>
		<input type="hidden" name="accio" value="enviar">
		<TD><font color="6198AB"><b>NOM DE CLIENT / CONTACTE</b></font></TD>
		<TD><INPUT value="" NAME="nombre" TYPE="TEXT" maxlength="128" size="20" ALIGN=left></TD>
		<TD><font color="6198AB"><b>TELFON</b></font></TD>
		<TD><INPUT value="" NAME="telefono" TYPE="TEXT" maxlength="14" size="14" ALIGN=left></TD>
		<TD><font color="6198AB"><b>MAIL</b></font></TD>
		<TD><INPUT value="" NAME="mail" TYPE="TEXT" maxlength="128" size="20" ALIGN=left></TD>
		</TR>
		
		<TR HEIGHT="30"><TD COLSPAN=6></TD></TR>
		
		<TR><TD COLSPAN=6>
Per a realitzar comandes de material de Editorial Arcada anar a <a href="http://www.editorialarcada.com" target="new">www.editorialarcada.com</a><p>

Esculli la opci que desitgi visualitzar. (Infantil i Primria o Secundria)</TD></TR>
		
		
		<tr height="35"><td COLSPAN=6></td></tr>
		<TR id="oc2">
			<td colspan=6 align=center>Esperi un moment si us plau....</td>
		</tr>
		<TR id="oc1" style="display:none">
		<TD></TD>
		<TD><A href="#" OnClick="hideLayer('secundaria');showLayer('primaria')"><font color="#6198AB"><b>INFANTIL i PRIMRIA</b></font></A></TD>
		<TD></TD>
		<TD><A href="#" OnClick="hideLayer('primaria');showLayer('secundaria')"><font color="#6198AB"><b>SECUNDRIA</b></font></A></TD>
		<TD colspan=2></TD>
		</TR>
		<TR HEIGHT="40"><TD colspan=6></TD></TR>
		<TR id="boton" style="display:none">
		<TD colspan=6 align=center><input type="image" src="../images/enviar.gif"><br><br>&nbsp;</TD>
		</TR>
	</TABLE>
	</CENTER>
	</TD>
	</TR>
</TABLE>
</CENTER>

<CENTER>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
	<TR bgcolor="ffffff">
		<td width="764" height="500">
			<CENTER>
